import React from 'react';
import cx from 'classnames';
import {findDOMNode} from "react-dom";
import { Input } from 'antd';

const { TextArea } = Input;

export default React.createClass({

    propTypes: {
        label: React.PropTypes.string.isRequired,
        isRequired: React.PropTypes.bool,
        rows: React.PropTypes.string,
        defaultValue: React.PropTypes.string,
    },

    getInitialState: function() {
        return {
            errMsg: null,
        };
    },

    componentWillReceiveProps: function(nextProps) {
        if(nextProps.defaultValue !== null && nextProps.defaultValue !== undefined){
            this.setState({value: nextProps.defaultValue});
        }
    },

    render: function() {
        return (
            <div>
                <div className="item-input jrh-textarea">
                    <span className="input-label">{this.props.label}</span>
                    <TextArea rows={this.props.rows} ref="textarea" value={this.state.value} onChange={this.change} />
                </div>
            </div>
        )
    },

    change: function(e){
        const value = e.target.value;
        this.setState({value: value});
    },

    getValue: function() {
        const value = this.state.value;
        return value;
    }
})
